package com.example.newstop.fragment;

import java.util.List;
import java.util.Map;

import com.example.newstop.R;
import com.example.newstop.adapter.SimpleRecyclerAdapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class MainFragment extends Fragment {
	
	private static List<Map<String, Object>> data;
	private static MainFragment mainFragment = new MainFragment();
	public MainFragment() {
		// TODO Auto-generated constructor stub
	}
	public static MainFragment newInstance(List<Map<String, Object>> data)
	{
		MainFragment.data = data;
		return mainFragment;
	}
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view =inflater.from(getActivity()).inflate(R.layout.fragment_main, null);
		RecyclerView recyclerView = (RecyclerView)view.findViewById(R.id.rv);
		recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
		SimpleRecyclerAdapter recyclerAdapter = new SimpleRecyclerAdapter(data);
		recyclerView.setAdapter(recyclerAdapter);
		return view;
	}
}
